Dimen Cache
EN Global, lock-free, shared cache for all AppDimens dimension calculations.
Thread Safety: Completely thread-safe. All reads and writes are lock-free using AtomicLongArray / AtomicIntegerArray. If two threads write identically-keyed entries simultaneously, the last write wins — always correct because both computed the same value.
PT Cache global, lock-free e compartilhado para todos os cálculos de dimensão do AppDimens.
Types
EN Cache usage statistics snapshot. The hits, misses, evictions, and hitRate fields are only meaningful when diagnosticsEnabled is true.
EN Calculation types based on the library's package structure. PT Tipos de cálculo baseados na estrutura de pacotes da biblioteca.
EN Holds all screen-derived scaling factors in an object padded to exceed two ARM64 cache lines (2 × 64 bytes = 128 bytes), ensuring that writes during updateFactors do not invalidate unrelated reads on sibling CPU cores.
EN Padded cache shard wrapper that prevents false sharing between shards across CPU cores on ARM64 (cache line = 64 bytes).
EN Dimension type discriminator for the cache key. PT Discriminador de tipo de dimensão para a chave de cache.
Properties
Number of slots in the primary (Tier-1) fast cache. Must be a power of 2 so that key and MASK is a fast modulo.
EN When true, hit/miss/eviction counters are incremented on every cache operation. Uses LongAdder for low-contention counting. Disabled by default so production apps pay zero overhead.
Internal flag to avoid AtomicBoolean.get overhead on every hot-path call.
EN Backward-compatible accessors — still referenced by DimenCacheTest. These are thin aliases into shards; no extra memory is allocated.
EN Cache Sharding (Concurrency Partitioning) Split the cache into 4 shards to reduce false sharing and bus contention.
EN Sharded, padded primitive cache storage. Replaces the previous keysArray / valueBitsArray pair. Each shard is wrapped in a ShardWrapper with 128-byte padding.
Functions
EN Registers a listener to be notified when the cache is cleared. PT Registra um listener para ser notificado quando o cache for limpo.
Packs all dimension-calculation parameters into a single 64-bit Long key.
EN Unified high-performance scaling engine. Reads from factors — padded object, guaranteeing that the read of scale and arMultiplier land on the same cache line as all other factor fields.
EN Clears all cache entries using AtomicLongArray.lazySet / AtomicIntegerArray.lazySet with 4× manual loop unrolling. This avoids issuing a full memory barrier on every element, which is safe because the next getOrPut will provide the required acquire/release semantics. Thread-safe.
EN Non-inline core logic for getOrPut. Separated so that the public inline function does not need access to internal fields of ShardWrapper directly. This function is @PublishedApi, making it visible to the inlined call-sites.
EN Selectively invalidates the cache based on what actually changed in Configuration.
EN Removes a previously registered reset listener. PT Remove um listener de reset previamente registrado.
EN Resets the diagnostic counters (hit, miss, eviction) to zero. PT Zera os contadores de diagnóstico (hit, miss, eviction).
EN Cancels the background persistence scope. Intended for test teardown. The scope is automatically re-created on next use (e.g. saveToPersistence).